#ifndef __NK_LOG_H__
#define __NK_LOG_H__

#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>

#define NKLOG_BUF_SIZE 1024
#define NKLOG_MAX_BUF_NR 1024

#define NKLOG_RING_PATH	"nklog_ring"
#define NKLOG_STATE_PATH "nklog_state"

enum {
	NKLOG_STATE_SLEEP,
	NKLOG_STATE_RUN,
};

struct nklog_state {
	int state;
	unsigned long long time;
};

struct nklog_buf {
	int mid;
	unsigned long long time;
	unsigned long long time2;
	char log[NKLOG_BUF_SIZE];
};


struct nklog_ring {
	short w;
	short r;
	int cpu;
	unsigned long long base_tsc;
	struct nklog_buf buf[NKLOG_MAX_BUF_NR];
};




extern int nklog_init(void);
extern int nklog_init_create(void);
extern int nklog_write(int mid, const char *msg);
extern int nklog_read(int fd, int cpu);
extern int nklog_read_all(int fd);


#endif
